<?php

/**
 * This is the model class for table "{{brand}}".
 *
 * The followings are the available columns in table '{{brand}}':
 * @property integer $zb_id
 * @property integer $zm_id
 * @property integer $zbc_id
 * @property integer $zb_commend
 * @property string $zb_title
 * @property string $zb_alias_name
 * @property string $zb_pic
 * @property string $zb_desc
 * @property integer $zb_hits
 * @property integer $zb_ranks
 * @property string $zb_letter
 * @property integer $inputtime
 * @property integer $updatetime
 */
class Brand extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Brand the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{brand}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('zm_id, zbc_id', 'required'),
			array('zm_id, zbc_id, zb_commend, zb_hits, zb_ranks, inputtime, updatetime', 'numerical', 'integerOnly'=>true),
			array('zb_title, zb_alias_name', 'length', 'max'=>100),
			array('zb_pic', 'length', 'max'=>255),
			array('zb_letter', 'length', 'max'=>2),
			array('zb_desc', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('zb_id, zm_id, zbc_id, zb_commend, zb_title, zb_alias_name, zb_pic, zb_desc, zb_hits, zb_ranks, zb_letter, inputtime, updatetime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'zb_id' => 'Zb',
			'zm_id' => 'Zm',
			'zbc_id' => 'Zbc',
			'zb_commend' => 'Zb Commend',
			'zb_title' => 'Zb Title',
			'zb_alias_name' => 'Zb Alias Name',
			'zb_pic' => 'Zb Pic',
			'zb_desc' => 'Zb Desc',
			'zb_hits' => 'Zb Hits',
			'zb_ranks' => 'Zb Ranks',
			'zb_letter' => 'Zb Letter',
			'inputtime' => 'Inputtime',
			'updatetime' => 'Updatetime',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('zb_id',$this->zb_id);
		$criteria->compare('zm_id',$this->zm_id);
		$criteria->compare('zbc_id',$this->zbc_id);
		$criteria->compare('zb_commend',$this->zb_commend);
		$criteria->compare('zb_title',$this->zb_title,true);
		$criteria->compare('zb_alias_name',$this->zb_alias_name,true);
		$criteria->compare('zb_pic',$this->zb_pic,true);
		$criteria->compare('zb_desc',$this->zb_desc,true);
		$criteria->compare('zb_hits',$this->zb_hits);
		$criteria->compare('zb_ranks',$this->zb_ranks);
		$criteria->compare('zb_letter',$this->zb_letter,true);
		$criteria->compare('inputtime',$this->inputtime);
		$criteria->compare('updatetime',$this->updatetime);

		$criteria->order = " inputtime DESC ";//默认为时间倒序
		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}